<template>
	<yd-layout id='my' class=''>
		<div class="header">
			<img class="header_img" src="../../assets/my_1.png" alt="" />
			<div class="header_content">
				<div class="header_top">
					<img class="header_top_left_img" :src="dataObj.avatar" alt="" />
					<div class="header_top_right" @click="goNext('set')">
						<div class="header_top_name">
							<span class="c_text_ellipsis_1">{{dataObj.nick_name}}</span>
							<div v-if="dataObj.group_name" class="header_top_label">{{dataObj.group_name}}{{dataObj.level_name}}</div>
							<template v-if="false">
								<img v-if="dataObj.member_status==1" class="header_vip" src="../../assets/vip_2.png" alt="" />
								<img class="header_vip" v-if='dataObj.member_status==2' src="../../assets/vip_1.png" alt="" />
							</template>
						</div> 
						<div class="header_top_id">ID:{{dataObj.id}}</div>
					</div>
					<img @click="goNext('set')" class="header_top_right_img" src="../../assets/bd_img/right.png" alt="" />
				</div>
				<div class="header_bottm">
					<div class="header_bottom_list">
						<div @click="goNext('myCollect')" class="header_bottom_num">{{collectCount}}</div>
						<div @click="goNext('myCollect')" class="header_bottom_label">我的收藏</div>
					</div>
					<div class="header_bottom_list">
						<!--{{commentCount}}-->
						<div @click="goNext('myHeart')"  class="header_bottom_num">0</div>
						<div @click="goNext('myHeart')" class="header_bottom_label">我的心声</div>
					</div>
					<div class="header_bottom_list">
						<div @click="goNext('myStudy')"  class="header_bottom_num">{{learnCount}}</div>
						<div @click="goNext('myStudy')"  class="header_bottom_label">学习记录</div>
					</div>
				</div>
			</div>
		</div>
		<div class="list">
			<div class="list_item" @click="goNext('wallet')">
				<img src="../../assets/my_3.png" alt="" />
				<span class="c_size_34_48">钱包</span>
				<i></i>
			</div>
			<div class="list_item" v-if="false" @click="goNext('vipOpen')">
				<img src="../../assets/my_2.png" alt="" />
				<span  class="list_item_time c_size_34_48">
					<div>商学院会员</div>
					<div class="list_item_time_c" v-if="dataObj.member_status==1">{{dataObj.newTime}}&nbsp;到期</div>
					<div class="list_item_time_c" v-else-if="dataObj.member_status==2">已到期</div>
					<div class="list_item_time_c" v-else>未开通</div>
				</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext()">
				<img src="../../assets/my_4.png" alt="" />
				<span class="c_size_34_48">开直播</span>
				<i></i>
			</div>
			<!--style="border-bottom: .2rem solid #FAFAFA ;"-->
			<div class="list_item" @click="goNext('set',true)" >
				<img src="../../assets/my_8.png" alt="" />
				<span class="c_size_34_48">我的名片</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext('myOrder')" style="border-bottom: .2rem solid #FAFAFA ;">
				<img src="../../assets/my_7.png" alt="" />
				<span class="c_size_34_48">我的订单</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext('myShareApp')">
				<img src="../../assets/my_5.png" alt="" />
				<span class="c_size_34_48">下载商学院APP</span>
				<i></i>
			</div>
			
			
			<div class="list_item" @click="goNext('set')" style="border-bottom: none;">
				<img src="../../assets/my_6.png" alt="" />
				<span class="c_size_34_48">设置</span>
				<i></i>
			</div>
		</div>
		<!--路由套壳的感觉差不多-->
		<Footer slot='bottom'  activeStr='my'></Footer>
	</yd-layout>
</template>

<script>
	import Footer from '../../components/Footer/Footer.vue'
	export default{
		components:{
			[Footer.name]:Footer
		},
		data(){
			return {
				dataObj:{},
				collectCount:0,
				learnCount:0,
				commentCount:0,
			}
		},
		created() {
		},
		watch: {
			
		},
		computed: {
			
		},
		mounted(){
			document.title='我的'
			this.$root.ajax({
				name:'my/index',
				type:'get',
				params:{
					
				}
			}).then((d)=>{
				d.data.user.newTime = this.$root.getDate(new Date(d.data.user.member_exp*1000))
				this.dataObj=Object.assign({},this.dataObj,d.data.user)
				this.collectCount = d.data.collect_count
				this.learnCount = d.data.learn_count
				this.commentCount = d.data.comment_count
			})
		},
		methods:{
			goNext(str,flg){
				
				if(str){
					let params={
						name:str
					}
					if(str=='myHeart'){
						params.query={uid:this.dataObj.id}
						this.$router.push(params)
					}else if(str=='myShareApp'){ 
						window.location=this.$root.config.downAppUrl
					}else if(flg){
						this.$router.push({
							name:str,
							query:{
								type:1
							}
						})
					}else{
						this.$router.push(params)
					}
					
				}else{
					this.$dialog.confirm({
	                    title: '温馨提示',
	                    mes: '微信端暂不支持开直播',
	                    opts: [
	                        {
	                            txt: '知道了',
	                            color: '#DCBBC9',
	                            callback: () => {
	                            	
	                            }
	                        }
	                    ]
	                });
				}
			}
		}
	}
</script>

<style lang="scss">
	@import './my.scss';
</style>